package com.mywork.entity.commom;


public class CommonResult {


    private int status;
    private String msg;
    private String voice;
    private Object data;

    public CommonResult(int status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public CommonResult(int status, String msg, Object data, String voice) {
        this.status = status;
        this.msg = msg;
        this.voice = voice;
        this.data = data;
    }

    public CommonResult(int status, String msg) {
        this.status = status;
        this.msg = msg;
        this.voice = "";
        this.data = null;
    }

    public CommonResult(CommonCode commonCode) {
        this.status = commonCode.status;
        this.msg = commonCode.msg;
        this.voice = commonCode.voice;
        this.data = null;
    }

    public CommonResult(CommonCode commonCode, Object data) {
        this.status = commonCode.status;
        this.msg = commonCode.msg;
        this.voice = commonCode.voice;
        this.data = data;
    }

    public static CommonResult success(Object data) {
        return new CommonResult(CommonCode.SUCCESS, data);
    }

    public static CommonResult success() {
        return new CommonResult(CommonCode.SUCCESS);
    }


    public static CommonResult error() {
        return new CommonResult(CommonCode.DEFEATED);
    }

    /**
     * 失败
     */
    public static CommonResult error(CommonCode commonCode) {
        return new CommonResult(commonCode);
    }

    /**
     * 失败
     */
    public static CommonResult error(Integer status, String message) {
        return new CommonResult(status, message);
    }

    public static CommonResult paramError() {
        return new CommonResult(CommonCode.PARAMERROR);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getVoice() {
        return voice;
    }

    public void setVoice(String voice) {
        this.voice = voice;
    }



}
